<template>
    <div id="audit">
        <el-form :inline="true" :model="query" size="mini">
            <el-form-item label="商品品牌：">
                <el-input v-model.trim="query.gname"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button icon='el-icon-search' type="primary" @click="handleCheck">查询</el-button>
                <el-button icon='el-icon-refresh' class="filter-item" @click="handleReset">刷新页面</el-button>
            </el-form-item>
        </el-form>

        <el-table
                :data="newgoodsData"
                style="width: 100%"
                border
                row-key="id"
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                :default-expand-all="false">
            <el-table-column
                    prop="id"
                    label="编号"
                    width="170"
            >
            </el-table-column>
            <el-table-column
                    prop="gname"
                    label="商品名称"
                    width="80"
            >
            </el-table-column>
            <el-table-column
                    prop="img"
                    label="商品图片"
                    width="80"
            >
                <template slot-scope="scope">
                    <el-popover placement="right" trigger="hover">
                        <img :src="scope.row.img" width="250" height="200">
                        <img slot="reference" :src="scope.row.img"  style="width:70px;height:35px">
                    </el-popover>
                </template>
            </el-table-column>
            <el-table-column
                    prop="description"
                    label="商品描述"
                    width="80"
            >
            </el-table-column>
            <el-table-column
                    prop="code"
                    label="商品编码"
                    width="80"
            >
            </el-table-column>
            <el-table-column

                    prop="typename"
                    label="商品类别"

            >
            </el-table-column>
            <el-table-column

                    prop="gsname"
                    label="商品规格"
            >
            </el-table-column>
            <el-table-column

                    prop="gbname"
                    label="商品品牌"
            >
            </el-table-column>
            <el-table-column

                    prop="gdname"
                    label="存储方式"
            >
            </el-table-column>

            <el-table-column
                    prop="start"
                    label="审核状态">
                <template slot-scope="scope">
                    <el-tag   v-if="scope.row.start==2">等待审核</el-tag>
                    <el-tag type="success" v-if="scope.row.start==0">审核通过</el-tag>
                    <el-tag type="danger" v-if="scope.row.start==1">审核驳回</el-tag>
                </template>
            </el-table-column>
            <el-table-column

                    prop="msg"
                    label="驳回理由"
            >
            </el-table-column>
            <el-table-column

                    prop="uname"
                    label="审核人"
            >
            </el-table-column>
            <el-table-column

                    prop="gmt_create"
                    label="创建时间"
            >
            </el-table-column>
            <el-table-column

                    prop="gmt_modified"
                    label="更新时间"
            >
            </el-table-column>


        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="pageSizes"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name: "audit",
        data(){
            return {
                query:{},
                //驳回理由内容
                bohuifrom:{},
                newgoodsData:[],
                //当前页数
                currentPage:1,
                pageSizes:[5,10,15,20],
                //每页显示的条数
                pageSize:5,
                //总条数
                total:0,
                //弹出框状态
                dialogVisible:false,
            }
        },
        created() {
            this.newgoods()
        },
        methods:{
            handleReset(){
                location.href="/goods/newgoods/audit"
            },
            //每页显示的条数发生改变时触发
            handleSizeChange(val) {
                this.pageSize=val;
                this.newgoods()
            },
            //当前页码发生改变时触发
            handleCurrentChange(val) {
                this.currentPage=val;
                this.newgoods()
            },
            handleCheck() {
                this.newgoods();
            },

            newgoods(){
                var that =this
                this.$http.post('/goods/newgoods/audit/'+this.currentPage+"/"+this.pageSize,this.query).then(function (resp) {
                    that.newgoodsData=resp.data.data.records
                     that.total=resp.data.data.total
                })
            },
        }
    }
</script>

<style scoped>

</style>